package com.dnkj.tribbon.service;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

/**
 * 调用别的服务的测试服务接口
 */

@Service
public class TestzService {

    @Autowired
    RestTemplate restTemplate;

    /**
     * 调用t-client服务中的  /hi  接口
     * @return
     */
    @HystrixCommand(fallbackMethod = "hiError")//断路注解,如果T-CLIENT服务挂了,访问hiError方法
    public String hi1(){
       return restTemplate.getForObject("http://T-CLIENT/hi",String.class);
    }

    public String hiError(){
        return "hi1 is error";
    }

}
